# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=hidapi
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_pre=rc1
pkgver=0.8.0${_pre}
pkgrel=3
pkgdesc="Library for communicating with USB and Bluetooth HID devices (mingw-w64)"
arch=('any')
url="http://www.signal11.us/oss/hidapi/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('staticlibs' 'strip')
source=("https://github.com/signal11/hidapi/archive/${_realname}-${pkgver//${_pre}/-${_pre}}.tar.gz")
sha256sums=('3c147200bf48a04c1e927cd81589c5ddceff61e6dac137a605f6ac9793f4af61')

prepare() {
  cd ${srcdir}/${_realname}-${_realname}-${pkgver//${_pre}/-${_pre}}
  autoreconf -vif
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${_realname}-${pkgver//${_pre}/-${_pre}}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-testgui
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
